package com.zx.auth.block.enums;

import lombok.Getter;

/**
 * <p>
 * description: OAuth2客户端认证方法枚举 <br>
 * create: 2025-11-12 15:30
 * </p>
 *
 * @author
 */
@Getter
public enum ClientAuthenticationMethodEnum {
    /**
     * 客户端密钥基础认证
     */
    CLIENT_SECRET_BASIC("client_secret_basic", "客户端密钥基础认证"),

    /**
     * 客户端密钥POST认证
     */
    CLIENT_SECRET_POST("client_secret_post", "客户端密钥POST认证"),

    /**
     * 客户端密钥JWT认证
     */
    CLIENT_SECRET_JWT("client_secret_jwt", "客户端密钥JWT认证"),

    /**
     * 私钥JWT认证
     */
    PRIVATE_KEY_JWT("private_key_jwt", "私钥JWT认证"),

    /**
     * 无认证
     */
    NONE("none", "无认证");

    /**
     * 认证方法值
     */
    private final String value;

    /**
     * 认证方法描述
     */
    private final String description;

    ClientAuthenticationMethodEnum(String value, String description) {
        this.value = value;
        this.description = description;
    }

    /**
     * 根据值获取认证方法枚举
     *
     * @param value 认证方法值
     * @return 认证方法枚举
     */
    public static ClientAuthenticationMethodEnum getByValue(String value) {
        for (ClientAuthenticationMethodEnum method : values()) {
            if (method.value.equals(value)) {
                return method;
            }
        }
        return null;
    }
}